/* 全局样式重置 */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji',
    'Segoe UI Emoji', 'Segoe UI Symbol';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root {
  height: 100%;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 代码编辑器样式 */
.monaco-editor {
  border: 1px solid #d9d9d9;
  border-radius: 6px;
}

.monaco-editor.focused {
  border-color: #40a9ff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

/* Monaco编辑器占位符样式 */
.editor-placeholder {
  opacity: 0.6;
}

.editor-placeholder-text {
  color: #999 !important;
  font-style: italic;
  white-space: pre-line;
}

/* SQL语法高亮自定义样式 */
.monaco-editor .token.keyword {
  color: #0000ff !important;
  font-weight: bold;
}

.monaco-editor .token.string {
  color: #008000 !important;
}

.monaco-editor .token.comment {
  color: #008000 !important;
  font-style: italic;
}

.monaco-editor .token.number {
  color: #ff0000 !important;
}

.monaco-editor .token.operator {
  color: #000000 !important;
}

.monaco-editor .token.predefined {
  color: #800080 !important;
  font-weight: bold;
}

/* 深色主题下的语法高亮 */
.monaco-editor.vs-dark .token.keyword {
  color: #569cd6 !important;
}

.monaco-editor.vs-dark .token.string {
  color: #ce9178 !important;
}

.monaco-editor.vs-dark .token.comment {
  color: #6a9955 !important;
}

.monaco-editor.vs-dark .token.number {
  color: #b5cea8 !important;
}

.monaco-editor.vs-dark .token.predefined {
  color: #dcdcaa !important;
}

/* 编辑器工具栏样式 */
.editor-toolbar {
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 6px 6px 0 0;
}

.editor-toolbar.dark {
  background: #1f1f1f;
  border-bottom-color: #303030;
}

.editor-toolbar .ant-btn {
  border: none;
  box-shadow: none;
}

.editor-toolbar .ant-btn:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.editor-toolbar.dark .ant-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

/* SQL验证器样式 */
.sql-validator {
  margin: 8px 0;
}

.sql-validator .ant-alert {
  border-radius: 6px;
}

.sql-validator .validation-details {
  max-height: 200px;
  overflow-y: auto;
}

.sql-validator .validation-item {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.sql-validator .validation-item.error {
  background: #fff2f0;
  border: 1px solid #ffccc7;
}

.sql-validator .validation-item.warning {
  background: #fffbe6;
  border: 1px solid #ffe58f;
}

.sql-validator .validation-item.info {
  background: #f6ffed;
  border: 1px solid #b7eb8f;
}

/* 代码片段样式 */
.sql-snippets .snippet-item {
  cursor: pointer;
  transition: background-color 0.3s;
}

.sql-snippets .snippet-item:hover {
  background-color: #f5f5f5;
}

.sql-snippets .snippet-code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 12px;
  background: #f5f5f5;
  padding: 8px;
  border-radius: 4px;
  white-space: pre-wrap;
  max-height: 100px;
  overflow: hidden;
}

/* 结果表格样式 */
.result-table .ant-table {
  font-size: 12px;
}

.result-table .ant-table-thead > tr > th {
  background: #fafafa;
  font-weight: 600;
  padding: 8px;
}

.result-table .ant-table-tbody > tr > td {
  padding: 6px 8px;
  word-break: break-all;
}

.result-table .ant-table-tbody > tr:hover > td {
  background: #f5f5f5;
}

/* 执行状态样式 */
.execution-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
}

.execution-status.executing {
  background: #e6f7ff;
  border-bottom-color: #91d5ff;
}

.execution-status.success {
  background: #f6ffed;
  border-bottom-color: #b7eb8f;
}

.execution-status.error {
  background: #fff2f0;
  border-bottom-color: #ffccc7;
}

/* 全屏模式样式 */
.fullscreen-editor {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: white;
}

.fullscreen-editor.dark {
  background: #141414;
}

/* 连接状态指示器 */
.connection-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.connection-indicator.active {
  background: #f6ffed;
  color: #52c41a;
  border: 1px solid #b7eb8f;
}

.connection-indicator.inactive {
  background: #fff2f0;
  color: #ff4d4f;
  border: 1px solid #ffccc7;
}

/* 响应式优化 */
@media (max-width: 768px) {
  .editor-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .editor-toolbar .ant-space {
    flex-wrap: wrap;
  }
  
  .result-table .ant-table {
    font-size: 11px;
  }
  
  .sql-validator .validation-details {
    max-height: 150px;
  }
}

/* 表格样式优化 */
.ant-table-thead > tr > th {
  background: #fafafa;
  font-weight: 600;
}

.ant-table-tbody > tr:hover > td {
  background: #f5f5f5;
}

/* 卡片样式 */
.ant-card {
  border-radius: 8px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02);
}

/* 按钮样式 */
.ant-btn {
  border-radius: 6px;
}

/* 输入框样式 */
.ant-input, .ant-select-selector {
  border-radius: 6px;
}

/* 标签样式 */
.script-tag {
  margin: 2px;
  border-radius: 12px;
}

/* 状态指示器 */
.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-running {
  background-color: #52c41a;
  animation: pulse 1.5s infinite;
}

.status-completed {
  background-color: #1890ff;
}

.status-failed {
  background-color: #ff4d4f;
}

.status-cancelled {
  background-color: #d9d9d9;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

/* 文件夹树样式 */
.folder-tree .ant-tree-node-content-wrapper {
  border-radius: 4px;
}

.folder-tree .ant-tree-node-content-wrapper:hover {
  background-color: #f5f5f5;
}

.folder-tree .ant-tree-node-selected .ant-tree-node-content-wrapper {
  background-color: #e6f7ff;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .ant-layout-sider {
    position: fixed !important;
    height: 100vh;
    z-index: 999;
  }
  
  .ant-layout-content {
    margin-left: 0 !important;
  }

  /* 移动端优化 */
  .ant-breadcrumb {
    display: none;
  }

  .ant-space {
    gap: 8px !important;
  }

  .ant-card {
    margin: 8px 0;
  }

  .ant-table-wrapper {
    overflow-x: auto;
  }
}

/* 状态栏样式 */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  z-index: 98;
  font-size: 12px;
}

/* 侧边栏动画 */
.ant-layout-sider {
  transition: all 0.2s ease-in-out;
}

.ant-layout-sider-collapsed .ant-menu-item-icon {
  font-size: 16px;
}

/* 头部样式优化 */
.ant-layout-header {
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
}

/* 面包屑样式 */
.ant-breadcrumb a {
  color: inherit;
  transition: color 0.3s;
}

.ant-breadcrumb a:hover {
  color: #1890ff;
}

/* 用户头像下拉菜单 */
.user-dropdown {
  cursor: pointer;
  transition: all 0.3s;
}

.user-dropdown:hover {
  background-color: rgba(0, 0, 0, 0.025);
  border-radius: 4px;
}

/* 通知徽章 */
.ant-badge-count {
  box-shadow: 0 0 0 1px #fff;
}

/* 快捷键帮助样式 */
.shortcut-key {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 12px;
  border: 1px solid #d9d9d9;
}

/* 设置面板样式 */
.settings-panel .ant-form-item {
  margin-bottom: 16px;
}

.settings-panel .ant-card {
  margin-bottom: 16px;
}

.settings-panel .ant-card-head {
  padding: 0 16px;
  min-height: 40px;
}

.settings-panel .ant-card-body {
  padding: 16px;
}

/* 主题切换动画 */
.theme-transition {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* 侧边栏快捷操作 */
.sidebar-quick-actions {
  padding: 8px 16px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-around;
  gap: 8px;
}

.sidebar-quick-actions .anticon {
  cursor: pointer;
  transition: color 0.3s;
}

.sidebar-quick-actions .anticon:hover {
  color: #1890ff;
}

/* 全屏模式优化 */
.fullscreen-mode .ant-layout-header {
  display: none;
}

.fullscreen-mode .ant-layout-content {
  margin: 0;
  padding: 0;
}

/* 加载状态 */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* 深色主题优化 */
.ant-layout.dark-theme {
  background: #141414;
}

.ant-layout.dark-theme .ant-layout-header {
  background: #001529;
  border-bottom-color: #303030;
}

.ant-layout.dark-theme .ant-layout-sider {
  background: #001529;
}

.ant-layout.dark-theme .status-bar {
  background: #001529;
  border-top-color: #303030;
  color: #fff;
}

/* 滚动条深色主题 */
.dark-theme ::-webkit-scrollbar-track {
  background: #2f2f2f;
}

.dark-theme ::-webkit-scrollbar-thumb {
  background: #555;
}

.dark-theme ::-webkit-scrollbar-thumb:hover {
  background: #777;
}

/* 工具提示样式 */
.ant-tooltip-inner {
  border-radius: 6px;
}

/* 模态框样式 */
.ant-modal-content {
  border-radius: 8px;
}

/* 抽屉样式 */
.ant-drawer-content {
  border-radius: 8px 0 0 8px;
}

/* 加载动画 */
.loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

/* 空状态样式 */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #999;
}

.empty-state .ant-empty-image {
  margin-bottom: 16px;
}

/* 代码差异展示 */
.diff-viewer {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
  line-height: 1.4;
}

.diff-line-added {
  background-color: #e6ffed;
  border-left: 3px solid #52c41a;
}

.diff-line-removed {
  background-color: #ffebe6;
  border-left: 3px solid #ff4d4f;
}

.diff-line-modified {
  background-color: #fff7e6;
  border-left: 3px solid #fa8c16;
}

/* 语法高亮 */
.sql-keyword {
  color: #1890ff;
  font-weight: bold;
}

.sql-string {
  color: #52c41a;
}

.sql-comment {
  color: #999;
  font-style: italic;
}

.sql-number {
  color: #fa8c16;
}

/* 自定义工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
  border-radius: 6px 6px 0 0;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: #d9d9d9;
  margin: 0 4px;
}

/* 结果表格 */
.result-table {
  margin-top: 16px;
}

.result-table .ant-table-container {
  border: 1px solid #f0f0f0;
  border-radius: 6px;
}

/* 执行状态标签 */
.execution-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* 版本时间线 */
.version-timeline .ant-timeline-item-content {
  margin-left: 16px;
}

.version-timeline .ant-timeline-item-head {
  background-color: #fff;
  border: 2px solid #1890ff;
}

/* 连接状态 */
.connection-status-online {
  color: #52c41a;
}

.connection-status-offline {
  color: #ff4d4f;
}

.connection-status-testing {
  color: #fa8c16;
}

/* 统计卡片 */
.stat-card {
  text-align: center;
  padding: 24px;
}

.stat-card .stat-number {
  font-size: 32px;
  font-weight: bold;
  color: #1890ff;
  margin-bottom: 8px;
}

.stat-card .stat-label {
  color: #666;
  font-size: 14px;
}